package com.dnw.presenter;

import com.dnw.base.BasePresenter;
import com.dnw.modle.Program;
import com.dnw.modle.Result;
import com.dnw.view.IProgramView;
import com.socks.library.KLog;

import java.util.List;

import rx.Subscriber;

/**
 * Created by yangyu on 2017/11/20.
 */

public class ProgramPresenter extends BasePresenter<IProgramView> {
    public ProgramPresenter(IProgramView view) {
        super(view);
    }

    public void getProgramResult() {
        addSubscription(mApiService.getProgram(), new Subscriber<Result<List<Program>>>() {
            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
                e.printStackTrace();
                KLog.e(e.getLocalizedMessage());
                mView.onError();
            }

            @Override
            public void onNext(Result<List<Program>> result) {
                mView.onGetProgramSuccess(result);
            }
        });
    }

}
